<?php $this->headLink()->appendStylesheet($this->dirCss.'/news.css');?>
<?php $this->headLink()->appendStylesheet($this->dirCss.'/UI_loading.css');?>
<?php
	$this->title = "Add Page";
	$this->headTitle ( $this->title );
?>
<?php echo $this->render('common/header.phtml'); ?>

<div id="deleteconfirm"><?php echo $this->language->l('deleteconfirm'); ?></div>
<!-- start content-outer ........................................................................................................................START -->
<div id="content-outer">
	
	<!-- start navigation -->
		<?php echo $this->render('common/navigation.phtml');?>
	<!-- END navigation -->
	
	<!-- start content -->
	<div id="content">
		
		<!--  start page-heading -->
		<div id="page-heading">
			<h1><?php echo $this->language->l('Page List');?></h1>
		</div>
		<!-- end page-heading -->
		
		
		<div id="content-border">
			<div class="list-header">
				<span class="top-left-title"><a href="javascript:"><?php echo $this->language->l('Id') ?></a></span>
				<span class="list-header-repeat line-left rep-img"><a href="javascript:"><?php echo $this->language->l('Representative image') ?></a></span>
				<span class="list-header-repeat line-left pt30"><a href="javascript:"><?php echo $this->language->l('Title'); ?></a></span>
				<span class="list-header-repeat line-left pt30"><a href="javascript:"><?php echo $this->language->l('Excerpt'); ?></a></span>
				<span class="list-header-options line-left "><a href="javascript:"><?php echo $this->language->l('Option') ?></a></span>
			</div>
			
			<div class="list-content">
				<?php foreach($this->newsList as $oneNews){?>
				<?php 
					//Process image
					if(empty($oneNews['represent_image'])){
						$oneNews['represent_image'] = 'noimage164x80.jpg';
					}
				?>
					<div class="one-news">
						<span class="id_"><?php echo $oneNews['id'];?></span>
						<span class="rep-img"><img style="width:100px; height:70px;" src="<?php echo $this->baseUrl('/public/images/system/'.$oneNews['represent_image']); ?>" alt=""  /></span>
						<span class="p-right9 pt30"><?php echo $oneNews['name']; ?></span>
						<span class="p-right9 pt30 excerpt"><?php echo strip_tags( $oneNews['excerpt']); ?></span>
						<span class="list-content-options">
							<span class="options-img">
								<a href="<?php echo $this->baseUrl('/admin/page/edit/id/'.$oneNews['id']); ?>" title="<?php echo $this->language->l("Edit");?>" class="icon-1 info-tooltip"></a>
								<a href="javascript:;" title="<?php echo $this->language->l("Delete");?>" class="icon-2 info-tooltip delete"></a>
								<?php if($oneNews['enabled'] == 1){?>
									<a href="javascript:" title="<?php echo $this->language->l("Click To Deactive");?>" class="icon-5 info-tooltip activate"></a>
								<?php }else{?>
									<a href="javascript:" title="<?php echo $this->language->l("Click To Active");?>" class="icon-5-deactive info-tooltip activate"></a>
								<?php }?>
							</span>
						</span>
					</div>
				<?php }?>
				
			</div><!--  END .list-content  -->
			
			<!--  start paging..................................................... -->
			<?php echo $this->paginationControl( $this->newsList, 'Sliding', 'common/pagination.phtml', array('language'=>$this->language) ); ?>
			<!--  end paging................ -->
			
		</div><!-- END #content-border -->
		
		
	</div><!--  end content -->
	
	<div class="clear">&nbsp;</div>
</div><!--  end content-outer........................................................END -->

<?php echo $this->render('common/footer.phtml'); ?>
<?php
	$moduleName 	= Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
	$controllerName = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
	$actionName 	= Zend_Controller_Front::getInstance()->getRequest()->getActionName();
	$urlName		= '/' . $moduleName . '/' . $controllerName . '/' ;
?>

<script type="text/javascript">
	//Define JS path
	var deletePath = '<?php echo $this->baseUrl().$urlName.'delete'?>';
	var activePath = '<?php echo $this->baseUrl().$urlName.'activate'?>';
	var loadingUrl = <?php echo '"'.$this->baseUrl('/public/images/system/loading.gif').'"' ?>;

	$(document).ready(function(){
		makeBalanceDiv();
	});

	function makeBalanceDiv(){
		//Cân bằng div
		var maxHeight = 10;
		$(".one-news span").each(function(){
			 if(maxHeight < parseInt( $(this).css('height') ))
				maxHeight = parseInt( $(this).css('height') );
		});
		$(".one-news span").not('.options-img').each(function(){
			$(this).css({'height':maxHeight+'px'});
			
		});

		//Cân bằng các cột trong nội dung
		$(".one-news span").not('.excerpt, ".list-content-options", ".options-img"').each(function(){
			$(this).css({'line-height':maxHeight+'px'});
		});

		//Cân bằng cột chứa hình
		$('.rep-img img').each(function(){
			var imgHeight = parseInt($(this).css('height'));
			var diffHeight = (maxHeight - imgHeight)/2;

			var imgWidth = parseInt($(this).css('width'));
			var diffWidth = (parseInt($(this).parent().css('width')) - imgWidth)/2;
			
			$(this).css({'margin-top':diffHeight+'px', 'margin-left':diffWidth+'px'});
		});

		//Cân bằng các nút trong cột option
		var width = $('.list-header-options').css('width');
		width = parseInt(width);
		width = (width - 98)/2;
		width = String(width) + "px";
		$('.options-img').css({"padding-left":width});

		maxHeight = (maxHeight - 24)/2;
		$('.options-img').css({"padding-top":maxHeight+"px"});

		//Cân bằng div viền bên ngoài
		var cao = 0;
		cao = cao + parseInt( $('.list-header').css('height'));
		cao = cao + parseInt( $('.list-content').css('height'));
		cao = cao + parseInt( $('#paging-table').css('height'));
		cao = cao + 40;
		$('#content-border').css({'height':cao+'px'});
		
	}
</script>